// write your code here
import java.util.*;
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int m = sc.nextInt();
            int n = sc.nextInt();
            if(0 == m*n){
                continue;
            }
            // 初始化地图数据，并找到起始位置
            char[][] map = new char[m][n];
            int x = 0,y = 0;
            for(int i = 0; i < m; ++i){
                String s = sc.next();
                for(int j = 0; j < n; ++j){
                    map[i][j] = s.charAt(j);
                    if('@' == map[i][j]){
                        x = i;
                        y = j;
                    }
                }
            }
            count = 0;
            dfs(map, x,y, m, n);
            System.out.println(count);
        }
    }
    static int count = 0;
    static byte[][] direct = {{-1, 0},{1, 0},{0,-1},{0,1}};
    public static void dfs(char[][] map, int x, int y, int row, int col){
        // 如果该位置是白砖，直接返回
        if('#' == map[x][y]){
            return;
        }
        // 说明(x, y)位置为黑砖, 将该砖遍历之后，修改其标记
        ++count;
        map[x][y] = '#';
        // 遍历该砖的四个方向
        for(int i = 0; i < 4; ++i){
            int nx = x + direct[i][0];
            int ny = y + direct[i][1];
            if(nx >= 0 && nx < row && ny >= 0 && ny < col){
                dfs(map, nx, ny, row, col);
            }
        }
    }
}
